<template>
    <div class="home_header">
        <div class="left">
            <img src="@/assets/img/logo.png" alt="">
            <div class="pingtai">学生信息成绩管理系统</div>
        </div>
        <div class="right">
            <ul class="list">
                <li @click="$router.push({name:'commonProblem'})">常见问题</li>
                <li @click="$router.push({
                    name: 'securityCenter'
                })">安全中心</li>
                <li @click="$router.push({ name: 'customerService' })">客服</li>
                <li @click="login_user">
                    {{ info }}
                </li>
                <li @click="exit">退出</li>
            </ul>
        </div>
    </div>
</template>

<script>
export default {
    computed: {
        info() {
            return this.$store.state.user_name ? this.$store.state.user_name : "登录"
        }
    },
    methods: {
        login_user() {
            if (this.$store.state.user_name) {
                this.$router.push({ name: 'personalCenter' })
            } else {
                this.$router.push({ name: 'login' })
            }
        },
        exit() {
            /*
                点击退出  要有哪些功能
                1、关闭当前浏览器标签；
                2、清空state当中的数据，实际上就是清空localStorage和sessionStorage。
            */
            //1、清空数据
            localStorage.clear();
            sessionStorage.clear();
            //2、关闭浏览器标签
            window.open("about:blank", "_self");
            window.close();
        }
    }
}
</script>

<style lang="scss" scoped>
.home_header {
    display: flex;
    justify-content: space-between;

    .left {
        display: flex;
        align-items: center;

        img {
            width: 100px;
            height: 100px;
        }

        .pingtai {
            display: flex;
            align-items: center;
            font-size: 40px;
            font-weight: 700;
            margin-left: 30px;
        }
    }

    .right {
        display: flex;
        align-items: flex-end;

        .list {
            display: flex;

            li {
                padding-right: 10px;
                padding-bottom: 10px;
            }
        }
    }
}
</style>